% test_DataMatrix

%%

clear classes
clc

%% Load the Matlab built-in 'iris' dataset

% iris.dat
%   1. sepal length in cm
%   2. sepal width in cm
%   3. petal length in cm
%   4. petal width in cm
%   5. class: 
%      -- Iris Setosa
%      -- Iris Versicolour
%      -- Iris Virginica

load iris.dat
zFetName = {'sepal_length', 'sepal_width', 'petal_length', 'petal_width'};
zLabName = {'iris_setosa', 'iris_versicolour', 'iris_virginica'};

X = iris(:, 1:4)/10;

Y = -ones(150, 3);
Y(  1: 50, 1) = 1;
Y( 51:100, 2) = 1;
Y(101:150, 3) = 1;

%% Test @DataMatrix::construct

zRowName = {''};
zColName = zFetName;
dmX = DataMatrix('iris_X', X, zRowName, zColName);
% dmX.showHead();

zRowName = {''};
zColName = zLabName;
dmY = DataMatrix('iris_Y', Y, zRowName, zColName);
% dmY.showHead();

%% Test @DataMatrix::clone

dmX2 = dmX.clone();

%% Test @DataMatrix::clone

dmX3 = DataMatrix();
duplicate(dmX3, dmX2);

%% Test @DataMatrix::setMat

dmX2.setMat(1);
dmX2.setMat(rand(3, 4), {'r'}, {'c'});
dmX2.setMat(rand(150, 4), {''}, {''});
% disp(dmX2.zRowName)
% disp(dmX2.zColName);

%% Test @DataMatrix::setZ[Row,Col]Name

%%% TOCOMMENT:
% Set all row/col names (with appending sequence number)
dmX2.setZRowName(':', {'r'}); % disp(dmX2.zRowName')
dmX2.setZColName(':', {'c'}); % disp(dmX2.zColName')

% Set specific row/col names
dmX2.setZRowName(1:3, {'r_01', 'r_02', 'r_03'}); % disp(dmX2.zRowName)
dmX2.setZRowName(dmX2.end('row'), {'r_end'}); % disp(dmX2.zRowName)
dmX2.setZColName(1, {'c_01'}); % disp(dmX2.zColName)
dmX2.setZColName(dmX2.end('col'), {'c_end'}); % disp(dmX2.zColName)

% Empty specific and all row/col names
dmX2.setZRowName(4); % disp(dmX2.zRowName)
dmX2.setZRowName(1:3); % disp(dmX2.zRowName)
dmX2.setZRowName(); % disp(dmX2.zRowName)
dmX2.setZColName(1); % disp(dmX2.zColName)
dmX2.setZColName(1:2); % disp(dmX2.zColName)
dmX2.setZColName(); % disp(dmX2.zColName)
